package com.xt.purchasingsystem.service.impl.productDesignServiceImpl.proFileManageServiceImpl.proFileDelManageServiceImpl;

import com.xt.purchasingsystem.dto.DFileDto;
import com.xt.purchasingsystem.mapper.DFileMapper;
import com.xt.purchasingsystem.model.DFile;
import com.xt.purchasingsystem.service.productDesignService.proFileManageService.proFileDelManageService.ProductFilecheckService;
import com.xt.purchasingsystem.utils.PageBean;
import com.xt.purchasingsystem.utils.Result;
import com.xt.purchasingsystem.utils.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional

public class ProductFilecheckServicelmpl implements ProductFilecheckService {
    @Autowired
    private DFileMapper dFileMapper;

    @Override
    public Result updateCheckTag(DFile dFile) {
        int i = dFileMapper.updateByPrimaryKey(dFile);
        if (i == 1) {
            return ResultFactory.buildSuccessResult("审核成功");
        } else {
            return ResultFactory.buildFailResult("审核失败");
        }

    }


    @Override
    public Result getAllDfile(DFileDto dfileDto) {
        int rowCount = dFileMapper.queryRowCountByAllDfile(dfileDto);
        PageBean pageBean = new PageBean(dfileDto.getPageSize(), dfileDto.getCurrNo(), rowCount);
        dfileDto.setCurrNo(pageBean.getStart());
        dfileDto.setPageSize(pageBean.getEnd());
        List<DFile> dFiles = dFileMapper.getAllDfile(dfileDto);
        pageBean.setPageList(dFiles);
        return ResultFactory.buildSuccessResult("查询成功", pageBean);
        }

    @Override
    public Result selectByid(Integer id) {
        DFile i=dFileMapper.selectByid(id) ;
         return ResultFactory.buildSuccessResult("查询成功");
    }



}


